% Figure 1 

axoptions={'scaled ticks = false',...
           'y tick label style={/pgf/number format/.cd, fixed, fixed zerofill,precision=0, set thousands separator={}}',...
           'x tick label style={/pgf/number format/.cd,precision=1, set thousands separator={}}',...
           'legend style={font=\normalsize}'}; %\scriptsize
U_true = u_vec(:,:,:);
v_vec_sort = v_vec(:,:,:) ;
medv_vecT = v_vec_sort(:,N/2,T);
pvec_b = pvec(:,:,1);
locusU = log(sum(paras.omega.*(((medv_vecT.^paras.eps_vec).*pvec_b).^(1-paras.sig))).^(1./(1-paras.sig)));
locusI = reshape(sum(paras.omega.*(((medv_vecT.^paras.eps_vec).*pvec).^(1-paras.sig))).^(1./(1-paras.sig)),[1,T]);
 
tmp = paras.omega.*(((medv_vecT.^paras.eps_vec).*pvec).^(1-paras.sig));
locusB = reshape(tmp./sum(tmp),[I,T]);
%  
sz = 10; 
if flag == 'nh'
    figure('name','Figure1(a)','Position',[100 100 1000 400],'NumberTitle','off')
else
    figure('name','Figure1(b)','Position',[100 100 1000 400],'NumberTitle','off')
end
subplot(1,2,1)
plot(B_vec(1,:,1),log(I_vec(1,:,1)),'LineWidth', 2);hold on
plot(B_vec(1,:,T/2),log(I_vec(1,:,T/2)),'LineWidth', 2) ;
plot(B_vec(1,:,T),log(I_vec(1,:,T)),'LineWidth', 2); 
plot(locusB(1,:),log(locusI),'LineWidth', 2);
scatter(locusB(1,1),log(locusI(1,1)),sz,'filled','MarkerEdgeColor','black',...
    'MarkerFaceColor',[0.4940 0.1840 0.5560])
scatter(locusB(1,T/2),log(locusI(1,T/2)),sz,'filled','MarkerEdgeColor','black',...
    'MarkerFaceColor',[0.4940 0.1840 0.5560])
scatter(locusB(1,T),log(locusI(1,T)),sz,'filled','MarkerEdgeColor','black',...
    'MarkerFaceColor',[0.4940 0.1840 0.5560])
ylabel('$\log I$','Interpreter','latex')
xlabel('Expenditure Share') 
title('Uncompensated')
if flag == 'nh'
    legend('$t_0$','$t_1$','$t_2$','Interpreter','latex')
else
    legend('$t_0$','$t_1$','$t_2$','Interpreter','latex','location','northwest')
end
ylim([2,8])
subplot(1,2,2)
plot(B_vec(1,:,1),log(U_true(:,:,1)),'LineWidth', 2);hold on
plot(B_vec(1,:,T/2),log(U_true(:,:,T/2)),'LineWidth', 2)
plot(B_vec(1,:,T),log(U_true(:,:,T)),'LineWidth', 2);
plot([locusB(1,1),locusB(1,T/2),locusB(1,T)],ones(1,3)*locusU,'LineWidth', 2)
scatter(locusB(1,1),locusU,sz,'filled','MarkerEdgeColor','black',...
    'MarkerFaceColor',[0.4940 0.1840 0.5560])
scatter(locusB(1,T/2),locusU,sz,'filled','MarkerEdgeColor','black',...
    'MarkerFaceColor',[0.4940 0.1840 0.5560])
scatter(locusB(1,T),locusU,sz,'filled','MarkerEdgeColor','black',...
    'MarkerFaceColor',[0.4940 0.1840 0.5560])
title('Compensated')
ylabel('$\log U$','Interpreter','latex')
xlabel('Expenditure Share')
if flag == 'nh'
 %   matlab2tikz('../fig/Hicksian-nh_example.tex');
else
%    matlab2tikz('../fig/Hicksian-h_example.tex');
end



